using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using AtletIS.DomainModel.Entities.Main;

namespace AtletIS.Database.Mapping.Main
{
    public class DisciplineMap : EntityTypeConfiguration<Discipline>
    {
        public DisciplineMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.Name)
                .IsRequired()
                .HasMaxLength(100);

            this.Property(t => t.AlterName)
                .HasMaxLength(100);

            this.Property(t => t.CodeName)
                .HasMaxLength(10);

            this.Property(t => t.Description)
                .HasMaxLength(100);

            this.Property(t => t.DisciplineGroupId)
                .HasMaxLength(5);

            // Table & Column Mappings
            this.ToTable("Disciplines");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.Name).HasColumnName("Name");
            this.Property(t => t.AlterName).HasColumnName("AlterName");
            this.Property(t => t.CodeName).HasColumnName("CodeName");
            this.Property(t => t.Description).HasColumnName("Description");
            this.Property(t => t.Code).HasColumnName("Code");
            this.Property(t => t.ResultCode).HasColumnName("ResultCode");
            this.Property(t => t.DisciplineGroupId).HasColumnName("DisciplineGroupId");
            this.Property(t => t.Active).HasColumnName("Active");
            this.Property(t => t.Sync).HasColumnName("Sync");
            this.Property(t => t.WebId).HasColumnName("WebId");
            this.Property(t => t.Modified).HasColumnName("Modified");

            // Relationships
            this.HasOptional(t => t.DisciplinesGroup)
                .WithMany(t => t.Disciplines)
                .HasForeignKey(d => d.DisciplineGroupId);

        }
    }
}
